import java.io.*;

public class T2B {
    public static void main(String[] args) throws FileNotFoundException {

        FileOutputStream fout = new FileOutputStream("20165233.bin");
        DataOutputStream dout = new DataOutputStream(fout);


        byte[] buffer = getByteFromFile("20165233.txt");

        int count, i;
        try
        {
            for (i = 0; i < buffer.length; i++)
            {
                dout.write(buffer[i]);
            }
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        finally
        {
            try
            {
                fout.close();
                dout.close();
            }
            catch (IOException ex2)
            {
                ex2.printStackTrace();
            }
        }

    }

    private static byte[] getByteFromFile(String file)
    {
        File f = new File(file);
        if (f == null)
        {
            return null;
        }
        try
        {
            FileInputStream stream = new FileInputStream(f);
            ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
            byte[] b = new byte[1024];
            int n;
            while ((n = stream.read(b)) != -1) {
                out.write(b, 0, n);
            }
            stream.close();
            out.close();
            return out.toByteArray();
        }
        catch (IOException e)
        {
        }
        return null;

    }
}
